package com.dao.impl;

import com.Bean.Fddate;
import com.Bean.RoomListFour;

import com.dao.StatisticsfourDao;
import com.util.JdbcUtil;

import java.sql.SQLException;
import java.util.List;

public class StatisticsDaofourlmpl implements StatisticsfourDao {


    public List<RoomListFour> queryDatafour(RoomListFour roomListFour, Fddate fddate) throws IllegalAccessException, SQLException, InstantiationException {
        String sql="select  lid,room_id.rid, room.rname,client.pname,client.pphone,room_list.out_status,intime,outtime,lsum, payment_term.sname " +
                "from room_list,room_id,room ,client,payment_term " +
                "where room_list.rid=room_id.rid and room_id.rtid=room.rtid and room_list.pno=client.pno and room_list.sid=payment_term.sid  HAVING 1=1";
        if(fddate.getLastDay()!=null){
            sql+=  " and intime BETWEEN  '"+fddate.getFristDay()+"'  and  '"+ fddate.getLastDay()+"'";
            System.out.println(sql);
        }
        //0,姓名 1,电话 2,订单号
        if(roomListFour.getInput()!=null&&roomListFour.getSelect()!=null){
            if (roomListFour.getSelect().equals("0")){
                sql+=" and client.pname = "+roomListFour.getInput();
            }else  if (roomListFour.getSelect().equals("1")){
                sql+=" and client.pphone = "+roomListFour.getInput();
            }else  if (roomListFour.getSelect().equals("2")){
                sql+=" and lid = "+roomListFour.getInput();
            }

        }

        return JdbcUtil.queryData(sql,RoomListFour.class);
    }


    @Override
    public int insert(RoomListFour roomListFour) throws SQLException {
        return 0;
    }

    @Override
    public List<RoomListFour> queryData(RoomListFour roomListFour) throws IllegalAccessException, SQLException, InstantiationException {
        return null;
    }

    @Override
    public int update(RoomListFour roomListFour) throws SQLException {
        return 0;
    }

    @Override
    public int deleteById(Object id) throws SQLException {
        return 0;
    }
}
